Technical Field
The present invention relates to an image inspection method and an inspection region setting method for performing appearance inspection with an image.
Background Art
For automation and labor savings for inspection in production lines, image inspection apparatuses that perform appearance inspection with an image have been widely used. Various types and methods of appearance inspection are available. In the basic configuration for the inspection, the desired inspection (for example, good/bad determination, sorting, or information acquisition) is performed by capturing an image of an inspection target object with an image sensor (camera), extracting a portion as an inspection region from the acquired image, and analyzing/evaluating the features of an image of the portion of the inspection region.
Image inspection apparatuses of this type need preparation work such as setting the inspection region, before inspection processing can be initiated. In a general apparatus, a dedicated tool for setting the inspection region is prepared, and the user himself or herself can use the tool to set an appropriate inspection region suitable for the inspection target object and an objective of the inspection. In recent years, there has been an increasing demand for minimizing setup time for improving the efficiency in small lot production of many kinds products. Thus, it is not preferable to take a long time for setting the inspection region. On the other hand, there has also been a strong demand for accurately fitting the inspection region to a portion to be the inspection target, to deal with a more complex product shape and more sophisticated and detailed inspection content, and to improve the accuracy and reliability of the inspection.
Some inspection target object might have individual difference in shape or have position/posture/scale varying in an image. For example, inspection of vegetables conveyed on a belt conveyer is considered. Vegetables all differ in shape, and cannot be accurately positioned. Thus, the position and the posture in the image differ among the inspection target objects. Furthermore, in the inspection of an industrial product such as a component mounting board, in a strict sense, the shape and the position of the components are not the same. Thus, to perform the inspection with high accuracy, the inspection region needs to be set for each inspection target object, or mismatch of the inspection region set in advance needs to be checked every time, and the inspection region needs to be set all over again, if required. These inhibit automatic inspection. When the inspection region is set to be sufficiently narrower than the inspection target object, the inspection region is less likely to be affected by the individual difference and the variation. Thus, the automatic inspection can be performed with the same inspection region. However, in the method, some portion might be excluded from the inspection region, and thus the method might lead to unsatisfactory inspection. A countermeasure of setting the range of the inspection region to be sufficiently large with respect to the inspection target object may be taken. However, with the method, the inspection region includes pixels of a portion (a background and other objects, for example) that has nothing to do with the inspection target object. Such pixels become noise, and thus, the inspection accuracy is degraded.
As a method for automatically setting the inspection region, an inspection region extraction method utilizing binarization and color gamut extraction, has conventionally been known. Specifically, the method includes extracting a pixel group, corresponding to a brightness range and color gamut set in advance, from an image, and setting the pixel group as the inspection region. The method is effective when there is a high contrast in brightness or a color between a portion (foreground) to be extracted as the inspection region and other portions (background). However, shading on the foreground portion due to lighting and the like, the foreground portion including various levels of brightness or various colors, and the background including a color that is similar to that of the foreground portion might make the accurate extraction of only the foreground portion difficult with the binarization and the color gamut extraction. In recent years, the inspection content has become highly sophisticated and more detailed. For example, there are many cases with almost no color difference between the foreground and the background, such as the surface inspection on only a single cutting surface in a molded component, and inspection on a single component on only a printed circuit board, on which a number of components are mounted. The binarization and the color gamut extraction are performed for each pixel in an image, and thus are likely to be affected by noise and change in lighting. The extracted inspection region might lack some pixels, or, conversely, pixels in the background portion might be selected as if some outlier is formed. Thus, the inspection accuracy is degraded.
Non Patent Literature 1 proposes a method of automatically extracting a contour of a target object (person or object) in an image. In the method, a shape model defining the contour shape of the target object is prepared, and is fit to the target object in an input image. Here, a calculation is repeated to minimize the error, by using the relationship between a position/posture/rotation parameter of the shape model and the feature quantity of the target object, as an evaluation value, so as to be capable of corresponding to the contour of a target object having a variable shape and position. In the method of Non Patent Literature 1, the processing of fitting the contour of the shape model to the target object in the input image is performed, based on the distribution of pixel values in the direction orthogonal to the contour line of the shape model. Here, the calculation needs to be repeated for a large number of times to minimize the shape model and the amount of information around the contour point of the target object, and thus, the calculation cost is extremely high.